package com.hzdl.springbootdemo.controller;

import com.hzdl.springbootdemo.util.HzdlAjaxResult;
import com.hzdl.springbootdemo.util.HzdlAjaxResult;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("error")
public class ErrorController {
    /**
     * 正常显示test页面
     * @return
     */
    @RequestMapping("toTest")
    public String toTest(){
        return "test";
    }

    /**
     * 异常,不能显示test页面
     * @return
     */
    @RequestMapping("toTestError")
    public String toTest2(){
        int a = 2/0;// 异常
        return "test";
    }

    @RequestMapping("getJson1")
    @ResponseBody
    public HzdlAjaxResult getJson(){
        return HzdlAjaxResult.ok(null);
    }

    @RequestMapping("getJsonError")
    @ResponseBody
    public HzdlAjaxResult getJson2(){
        int a = 2/0;// 异常
        return HzdlAjaxResult.ok(null);
    }
}
